
/**		
 * 
 *	uk.co.lmfm.guppy.controller.CloneWorkspaceCommand
 *	
 *	@version 1.00 | Jan 15, 2010
 *	@author Justin Windle
 *  
 **/
 
package uk.co.lmfm.guppy.controller 
{
	import uk.co.lmfm.guppy.model.EclipseProxy;
	import uk.co.lmfm.guppy.model.WorkspaceProxy;
	import uk.co.lmfm.guppy.model.SettingsProxy;
	import uk.co.lmfm.guppy.model.vo.CloneFileVO;
	import uk.co.lmfm.guppy.model.vo.SettingsVO;

	import org.osflash.thunderbolt.Logger;
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.command.SimpleCommand;

	/**
	 * CloneWorkspaceCommand
	 */
	public class CloneWorkspaceCommand extends SimpleCommand implements ICommand 
	{
		override public function execute(notification : INotification) : void
		{
			super.execute(notification);
			
			var workspaceProxy : WorkspaceProxy = facade.retrieveProxy(WorkspaceProxy.NAME) as WorkspaceProxy;			var eclipseProxy : EclipseProxy = facade.retrieveProxy(EclipseProxy.NAME) as EclipseProxy;
			var sqlProxy : SettingsProxy = facade.retrieveProxy(SettingsProxy.NAME) as SettingsProxy;
			
			var request : CloneFileVO = notification.getBody() as CloneFileVO;
			var settings : SettingsVO = sqlProxy.readSettings();
			
			Logger.info("Clone workspace: Source: " + request.source.nativePath + ", Destination: " + request.destination.nativePath);
			
			workspaceProxy.cloneWorkspace(request);
			eclipseProxy.addWorkspacePath(request.destination.nativePath, settings.eclipsePath);
		}
	}
}
